<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0044)http://demo.demohuo.top/modals/67/6769/demo/ -->

<title>图书管理系统</title>

<link rel="stylesheet" type="text/css" href="/static/default.css">

<link href="/static/index.css" rel="stylesheet">

<link href="/static/iconfont.css" rel="stylesheet">
    <style>
        .book{
            height: 600px;
            width: 726px;
        }
        .register{
            color: #0a98eb;
        }
        .register:hover{
            text-decoration: underline;
        }
        .error_tips{
            display: none;
        }
    </style>
</head>
<body style="height:100%;">

    <div class="boxer">
		<h2 class="logo"></h2>
		<div class="box1">
		    <div class="middle1">
		    	<div class="middle_left">
		    		<img src="/static/book.jpg" class="book">
		    	</div>
		    	<div class="middle_right">
		    		<div class="mr_box">
		    			<h2>欢迎登录</h2>
						<form>
                            {% csrf_token %}
							<div class="form-group login_input">
								<span class="iconfont icon-Profile icon_p"></span>
								  <input type="text" class="form-control icon-user" id="user" placeholder="请输入您的用户名">
							</div>
							<div class="form-group mar_b login_input">
								<span class="iconfont icon-Unlock icon_p"></span>
								  <input type="password" class="form-control icon-pass" id="pwd" placeholder="请输入您的密码">
							</div>
							<div class="form-check font-s">
								<div class="custom-control custom-checkbox small">
                                    <p >没有账号？<a href="/register/" class="register">注册用户</a></p>
							    </div>
							</div>
							<div class="f_pass">
								<div class="f_pass_n error_tips">
									<i class="fl"><img src="/static/sq.png"></i>
									<p>用户名密码错误或为空!</p>
								</div>
							</div>
							<button type="button" class="login">登录</button>
						</form>
		            </div>
		    	</div>
		    </div>
		</div>
    </div>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
    <script>
        $(".login").click(function () {
            $.ajax({
                url:"/login/",
                type:"post",
                data:{
                    csrfmiddlewaretoken: $("[name='csrfmiddlewaretoken']").val(),
                    user:$("#user").val(),
                    pwd:$("#pwd").val(),
                },
                success:function (data) {
                    console.log(data)
                    if (data.user){
                        $(".f_pass_n").addClass("error_tips")
                        location.href = "/index/"
                    }else {
                        $(".f_pass_n").removeClass("error_tips")
                    }

                }
            })
        })
        $(".login_input input").focus(function () {
              $(".f_pass_n").addClass("error_tips")
        })
    </script>

</body></html>